/*
Copyright (c) [2019年5月1日] [吴超]
[MBT_studio] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
		 http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
*/
#include "matXX.h"

#include <矩阵.h>

Mat44f f_mat44_构建XYZ旋转矩阵(const vec3& r) {
	
	auto rx = f_mat44_构建X旋转矩阵(r.x);
	auto ry = f_mat44_构建Y旋转矩阵(r.y);
	auto rz = f_mat44_构建Z旋转矩阵(r.z);
	
	return (rz * ry * rx);
}

Mat44f f_mat44_构建XYZ变换矩阵(const S_Tranform& t) {
    Mat44f mat;

    auto 全局缩放 = f_mat4_构建缩放矩阵(t.scale);
    //auto 局部缩放 = f_mat4_构建缩放矩阵(t.locScale);
    mat = f_mat44_构建移动矩阵(t.position) * f_mat44_构建XYZ旋转矩阵(t);
    mat *= 全局缩放;

    return mat;
}

Mat44f f_mat44_Invert(const Mat44f& 矩阵) {
	Mat44f inMat;
	f_Matrix4X4_InvertMatrixf2((float32*)&矩阵, (float32*)&inMat);
	return inMat;
}

mat4 f_mat4_Invert(const mat4& 矩阵) {
	mat4 inMat;
    f_Matrix4X4_InvertMatrixf2((float32*)&矩阵, (float32*)&inMat);
	return inMat;
}


